home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue57 / DragDrop / DllFormU.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-03-23  |  1.8 KB  |  70 lines

  1. unit DllFormU;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. type
  10.   TDLLForm = class(TForm)
  11.     Memo1: TMemo;
  12.     Label1: TLabel;
  13.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  14.     procedure Memo1MouseDown(Sender: TObject; Button: TMouseButton;
  15.       Shift: TShiftState; X, Y: Integer);
  16.     procedure Memo1StartDrag(Sender: TObject; var DragObject: TDragObject);
  17.     procedure Memo1EndDrag(Sender, Target: TObject; X, Y: Integer);
  18.   private
  19.     FDragObject: TDragObject;
  20.   public
  21.     { Public declarations }
  22.   end;
  23.  
  24. procedure ShowForm(ApplicationHandle: HWnd); stdcall;
  25.  
  26. implementation
  27.  
  28. uses
  29.   DLLDragObject;
  30.  
  31. {$R *.DFM}
  32.  
  33. procedure ShowForm(ApplicationHandle: HWnd); stdcall;
  34. begin
  35.   //Set Application object window handle to match that in the EXE,
  36.   //meaning we do not get another task bar button for the form
  37.   Application.Handle := ApplicationHandle;
  38.   TDLLForm.Create(Application).Show
  39. end;
  40.  
  41. procedure TDLLForm.FormClose(Sender: TObject; var Action: TCloseAction);
  42. begin
  43.   //The form frees itself when closed
  44.   Action := caFree
  45. end;
  46.  
  47. procedure TDLLForm.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
  48.   Shift: TShiftState; X, Y: Integer);
  49. begin
  50.   //Check for right mouse button, and no other buttons/keys
  51.   if Shift = [ssRight] then
  52.     (Sender as TCustomEdit).BeginDrag(True);
  53. end;
  54.  
  55. procedure TDLLForm.Memo1StartDrag(Sender: TObject;
  56.   var DragObject: TDragObject);
  57. begin
  58.   DragObject := TTextDragObject.Create;
  59.   TTextDragObject(DragObject).Data := (Sender as TMemo).SelText;
  60.   FDragObject := DragObject
  61. end;
  62.  
  63. procedure TDLLForm.Memo1EndDrag(Sender, Target: TObject; X, Y: Integer);
  64. begin
  65.   FDragObject.Free;
  66.   FDragObject := nil
  67. end;
  68.  
  69. end.
  70.